package com.xnccc.fragment;

import com.owen.mapx.MapX;
import com.xnccc.audioset.MainActivity;
import com.xnccc.audioset.R;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class BaseTestFragment extends Fragment {

	private MapX bird;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		bird = MainActivity.bird;
		View mView = inflater.inflate(R.layout.fragment_basetest, container, false);
		initView(mView);
		return mView;
	}

	private void initView(View mView) {
		mView.findViewById(R.id.btn_play).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				v.setSelected(!v.isSelected());
				if (v.isSelected()) {
					bird.switchSRC(MapX.SRC_ARM);
					((Button) v).setText("Stop");
					bird.setNoiseChannel(MapX.CH_L | MapX.CH_R | MapX.CH_C | MapX.CH_LFE);
				} else {
					bird.switchSRC(MapX.SRC_NOISE);
					bird.setNoiseMode(MapX.NOISE_FLAT);
					bird.setNoiseChannel(MapX.CH_NULL);
					((Button) v).setText("Play");
				}
			}
		});
	}

}
